-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-34484][SQL] Rename map to mapAttr in Catalyst DSL
#31601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Test build #135315 has finished for PR 31601 at commit
|
|
cc: @cloud-fan |
|
|
||
| // int type can be up cast to long type | ||
| val attrs1 = Seq('a.string, 'b.int) | ||
| val attrs1 = Seq(attr("a").string, attr("b").int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have "name".attr (See the implicit DslString), can we extend it to support "name".attr.string or even shorter "name".string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it's not enough. "name".attr returns UnresolvedAttribute as well as $"name" so we still fail to do "name".attr.map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My general idea is, previous the DSL is based on symbol, can we update the DSL (those implicts) so that it's based on string? Ideally we should simply replace 'abc to "abc" in the test code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was my first idea but I thought it might be confusable that "abc" with implicit conversion doesn't look like an attribute. But DSL is for internal so it might be acceptable. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we should simply replace 'abc to "abc" in the test code.
Yes ideally it should be like what you suggested but I found it's difficult.
DslString implements ImplicitOperators but DslSymbol implements ImplicitAttribute. The implementation of expr conflicts. DslString implements expr as Literal but DslSymbol implements it as UnresolvedExpression.
So, the next option would be introduce a new syntax like attr"" with StringContext.
I said in the description like as follows.
Another solution would be to introduce a new string interpolation syntax but it's difficult to have workaround when the syntax is conflict with another string interpolation syntax like that $"" defined in catalyst and core conflict so I don't adopt this solution.
But if this is internal usage only, it might be acceptable.
|
Test build #135348 has finished for PR 31601 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
cc: @dongjoon-hyun and @HyukjinKwon too for other people's opinion. |
|
Test build #135351 has finished for PR 31601 at commit
|
|
I agree that the |
|
Thanks for the advice. Renamed |
|
Test build #135412 has finished for PR 31601 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/dsl/package.scala
Show resolved
Hide resolved
cloud-fan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please update the PR title
|
Kubernetes integration test unable to build dist. exiting with code: 1 |
|
Test build #135490 has finished for PR 31601 at commit
|
|
Newly added |
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #135492 has finished for PR 31601 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #135517 has finished for PR 31601 at commit
|
|
@cloud-fan According to this, should we wait for what happens as a result of the discussion? |
|
Is there a released Scala version that forbids the symbol's literal syntax? |
|
No, but we get warning with Scala 2.13. EDIT: dotty seems not to support symbol literals. |
|
OK seems the ship is already sailed. Let's wait a bit more but I'm not sure we can change that decision... |
Yeah, I think so too. At least, symbol literals will be no longer supported as dotty already removed them. |
e03dca2 to
506bf5b
Compare
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
@cloud-fan Surprisingly, Scala 3 seems to implement the backward compatibility feature for symbol literals (it may be a life extension measure, however). So, I think replacing symbol literals with |
|
If scala will keep that backward compatibility feature forever, then we don't need to do anything. Otherwise, we still need to prepare for the removal of the symbol syntax. |
According to this, it seems to be a life extension measure and will be removed in the future. |
|
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable. |
What changes were proposed in this pull request?
This PR proposes to rename
maptomapAttrindsl/package.scala.This PR also removes APIs which take
Symboltype parameters.Why are the changes needed?
With the Catalyst DSL (
dsl/package.scala), we have two ways to represent attributes.'syntax)$""syntax which is defined insql/catalystmodule using string context.But they have problems.
Regarding symbol literals, the scala community deprecates the symbol literals in Scala 2.13. We could alternatively use
Symbolconstructor but what is worse, Scala will completely removeSymbolin the future (https://scalacenter.github.io/scala-3-migration-guide/docs/incompatibilities/dropped-features.html).Regarding
$""syntax, this has two problems.The first problem is that the syntax conflicts with another
$""syntax defined insql/coremodule.You can easily see the problem with the Spark Shell.
The second problem is that we can't write like
$"attr".map(StringType, StringType), though we can write'attr.map(StringType, StringType).This seems to be a bug of the Scala compiler and will be fixed in neither
2.12nor2.13(scala/scala#7396).Actually, I'm working on replacing all the symbol literals with
$""syntax in SPARK-34443 (#31569) and I found this problem in the following test code.As a solution for those problems, I propose to rename
maptomapAttr.With this solution, we can write
"name".attr.mapAttrrather than$"name".mapor'name.map.Does this PR introduce any user-facing change?
No.
dsl/package.scalais for internal use.How was this patch tested?
Modified the tests.